# CONFIG FOR Cherry v2.0
# UlTi Steel 300
#
# NOTE Lines must not exceed 132 characters, and '#' characters mean what follows is ignored
## Robot module configurations : general handling of movement G-codes and slicing into moves
######################## Basic USB port settings ########################

usb_uart_baudrate                                       115200

######################## Basic motion configuration ########################

single_head 								true

# Arm solution configuration : Cartesian robot. Translates mm positions into stepper positions
arm_solution 								cartesian		  			# Type of kinematics
alpha_steps_per_mm 							80               			# Steps per mm for alpha ( X ) stepper
beta_steps_per_mm 							80               			# Steps per mm for beta ( Y ) stepper
gamma_steps_per_mm 							800             			# Steps per mm for gamma ( Z ) stepper

# Cartesian axis speed limits
x_axis_max_speed_mmps 						300 						# Maximum speed in mm/sec
y_axis_max_speed_mmps 						300            				# Maximum speed in mm/sec
z_axis_max_speed_mmps 						15 							# Maximum speed in mm/sec

# Default speed
default_feed_rate_mmps 						80             				# Default speed (mm/sec) for G1/G2/G3 moves
default_seek_rate_mmps 						80              			# Default speed (mm/sec) for G0 moves

# Acceleration configuration
acceleration 								3000 						# Acceleration in mm/s^2
z_acceleration 								15 							# Acceleration for Z only moves in mm/s^2, 0 uses acceleration which is the default. DO NOT SET ON A DELTA
junction_deviation 							0.01 						# Junction deviation value
z_junction_deviation 						0.01 						# For Z only moves, -1 uses junction_deviation, zero disables junction_deviation on z moves DO NOT SET ON A DELTA
minimum_cruise_ratio 						0.5 						#         

# Cartesian acceleration limits
alpha_acceleration 							3000						# Acceleration in mm/s^2
beta_acceleration 							3000						# Acceleration in mm/s^2
gamma_acceleration 							20 						# Acceleration in mm/s^2


######################## Stepper module configuration ########################
# Pins are defined as  ports, and pin numbers, appending "!" to the number will invert a pin

# X Axis stepper configuration
alpha_step_pin 								d.13						# Pin for alpha/X stepper step signal
alpha_dir_pin 								d.14!						# Pin for alpha/X stepper direction, add '!' to reverse direction
alpha_en_pin 								d.15						# Pin for alpha/X enable pin
alpha_max_rate_mmps 						300							# Maximum rate in mm/sec

# Y Axis stepper configuration
beta_step_pin 								e.8							# Pin for beta/Y stepper step signal
beta_dir_pin 								e.7!						# Pin for beta/Y stepper direction, add '!' to reverse direction
beta_en_pin 								e.10						# Pin for beta/Y enable pin
beta_max_rate_mmps 							300							# Maximum rate in mm/sec

# Z Axis stepper configuration
gamma_step_pin 								d.3             			# Pin for gamma/Z stepper step signal
gamma_dir_pin 								d.7!             			# Pin for gamma/Z stepper direction, add '!' to reverse direction
gamma_en_pin 								d.4             			# Pin for gamma/Z enable
gamma_max_rate_mmps 						20.0          				# Maxmimum rate in mm/sec


######################## Extruder module configuration ########################

extruder.hotend.enable                        true          			# Whether to activate the extruder module at all. All configuration is ignored if false
extruder.hotend.steps_per_mm                  148.50           			# Steps per mm for extruder stepper
extruder.hotend.default_feed_rate_mmps        100            			# Default rate ( mm/sec ) for moves where only the extruder moves
extruder.hotend.acceleration                  10000           			# Acceleration for the stepper motor mm/s^2
extruder.hotend.max_speed                     100            			# Maximum speed in mm/s

extruder.hotend.step_pin                      c.4          				# Pin for extruder step signal
extruder.hotend.dir_pin                       c.1!          				# Pin for extruder dir signal ( add '!' to reverse direction )
extruder.hotend.en_pin                        c.0          				# Pin for extruder enable signal

# Extruder offset
extruder.hotend.x_offset                      0           				# X offset from origin in mm
extruder.hotend.y_offset                      0           				# Y offset from origin in mm
extruder.hotend.z_offset                      0            				# Z offset from origin in mm
extruder.hotend.tool_number                   0  


######################## Temperature control configuration ########################

## First hotend configuration
temperature_control.hotend.enable            	true             		# Whether to activate this ( "hotend" ) module at all.
temperature_control.hotend.sensor            	thermistor				#  
temperature_control.hotend.thermistor        	Semitec		  			# Thermistor type 
temperature_control.hotend.thermistor_pin    	a.0              		# Pin for the thermistor to read

temperature_control.hotend.heater_pin        	b.5 					# Pin that controls the heater, set to nc if a readonly thermistor is being defined
temperature_control.hotend.use_hwpwm            true					#   

temperature_control.hotend.set_m_code        	104              		# M-code to set the temperature for this module
temperature_control.hotend.set_and_wait_m_code 	109            			# M-code to set-and-wait for this module
temperature_control.hotend.designator        	T0               		# Designator letter for this module
temperature_control.hotend.max_temp          	300              		# Set maximum temperature - Will prevent heating above 300 by default
temperature_control.hotend.thermal_overshoot    5						#       ,    Max_Temp
temperature_control.hotend.min_temp          	5                		# Set minimum temperature - Will prevent heating below if set
minimal_extrusion_temp			    		    50						# ,      

# Safety control first hotend
temperature_control.hotend.target_temp_safezone         	2			# Safety control is enabled by default and can be overidden here, the values show the defaults

temperature_control.hotend.heating_watch_temp_period      	40			#        xx .  .
temperature_control.hotend.heating_watch_temp_increase    	4			#  ,  C.

temperature_control.hotend.thermal_protection_period      	60			#           
temperature_control.hotend.thermal_protection_hysteresis  	15			#   

temperature_control.hotend.runaway_heating_timeout 			600     	# How long it can take to heat up, max is 2040 seconds.
temperature_control.hotend.runaway_cooling_timeout 			0     		# How long it can take to cool down if temp is set lower, max is 2040 seconds
temperature_control.hotend.runaway_range 					0    		# How far from the set temperature it can wander, max setting is 63?C

temperature_control.hotend.idle_time 						1800		#      ,     


# PID configuration first hotend
temperature_control.hotend.p_factor         	19.32            		# P ( proportional ) factor
temperature_control.hotend.i_factor         	0.402            		# I ( integral ) factor
temperature_control.hotend.d_factor         	178.77              	# D ( derivative ) factor
temperature_control.hotend.pidtype2            	true                	# Proportional on Measurement  not on Error!
temperature_control.hotend.PonE_weight          0.6						#     PID2
temperature_control.hotend.pid_distance         30               		# PID distance -    
temperature_control.hotend.min_pwm				15						#   . 0-255
temperature_control.hotend.min_set_temp         50						#      .

## Heating bed configuration
temperature_control.bed.enable            		true             		# Whether to activate this ( "hotend" ) module at all.
temperature_control.bed.thermistor_pin       	a.2              		# Pin for the thermistor to read
temperature_control.bed.heater_pin           	d.12              		# Pin that controls the heater
temperature_control.bed.thermistor           	Semitec     	  		# Thermistor type
temperature_control.bed.set_m_code           	140              		# M-code to set the temperature for this module
temperature_control.bed.set_and_wait_m_code  	190              		# M-code to set-and-wait for this module
temperature_control.bed.designator           	B                		# Designator letter for this module
temperature_control.bed.pidtype2             	false 					# Fast PID type
temperature_control.bed.pid_distance         	6               		# PID distance -    
temperature_control.bed.max_temp             	120              		# Set maximum temperature - Will prevent heating above 300 by default

# Bang-bang ( simplified ) control
temperature_control.bed.bang_bang            	false            		# Set to true to use bang bang control rather than PID
temperature_control.bed.hysteresis           	0.5              		# Set to the temperature in degrees C to use as hysteresis

# PID Bed control
temperature_control.bed.p_factor          		178.3           			# P ( proportional ) factor
temperature_control.bed.i_factor          		20.256          			# I ( integral ) factor
temperature_control.bed.d_factor          		392 						# D ( derivative ) factor

# Safety control is enabled by default and can be overidden here, the values show the defaults
temperature_control.bed.target_temp_safezone         	2			#    ,     

#       
temperature_control.bed.heating_watch_temp_period      	80			#        "heating_watch_temp_increase" . .
temperature_control.bed.heating_watch_temp_increase    	4			#  ,  C.

#    ,    . 
temperature_control.bed.thermal_protection_period      	60			#           
temperature_control.bed.thermal_protection_hysteresis  	15			#   

temperature_control.bed.runaway_heating_timeout      	800     	# How long it can take to heat up, max is 2040 seconds.
temperature_control.bed.runaway_cooling_timeout      	0     		# How long it can take to cool down if temp is set lower, max is 2040 seconds
temperature_control.bed.runaway_range                	0    		# How far from the set temperature it can wander, max setting is 63?C

temperature_control.bed.idle_time 						1800		#      ,     


######################## Switch modules ########################

# automatically toggle a switch at a specified temperature
# useful to turn on a fan or water pump to cool the hotend
temperatureswitch.hotend.enable	             	true             		# enable this module
temperatureswitch.hotend.switch                 fan_h             		# select which MOSFET to use, must match a switch configuration (fan2 below)
temperatureswitch.hotend.designator             T                		# first character of the temperature control designator to use as the temperature sensor to monitor
temperatureswitch.hotend.threshold_temp         50.0             		# temperature to turn on (if rising) or off the switch
temperatureswitch.hotend.heatup_poll            5               		# poll heatup at 15 sec intervals
temperatureswitch.hotend.cooldown_poll          15               		# poll cooldown at 60 sec intervals


# Auto start the cooler of the electronics compartment
temperatureswitch.elc.enable	             	true             		# enable this module
temperatureswitch.elc.switch                 	fan2             		# select which MOSFET to use, must match a switch configuration (fan2 below)
temperatureswitch.elc.designator             	DRIVER_ENABLE 			# first character of the temperature control designator to use as the temperature sensor to monitor
temperatureswitch.elc.heatup_poll            	5               		# poll heatup at 15 sec intervals
temperatureswitch.elc.cooldown_poll          	15               		# poll cooldown at 60 sec intervals

# Switch module for HotEnd fan control
switch.fan_h.enable                          	true					# Enable this module
switch.fan_h.output_type                     	hwpwm						#
switch.fan_h.output_pin                      	b.4					#  .  Head2   Cherry3d
switch.fan_h.max_pwm                         	255						# Set max pwm for the pin default is 255
switch.fan_h.kickstart_time                  	100
switch.fan_h.ignore_on_halt  		    	 	true					#set to true to not set the failsafe or startup_value value when a HALT condition is triggered
switch.fan_h.kickstart_time                   	100
switch.fan_h.ignore_on_halt  		    	 	true

# Switch module for model fan control
switch.fan0.enable                           	true             		# Enable this module
switch.fan0.input_on_command                 	M106             		# Command that will turn this switch on
switch.fan0.input_off_command                	M107             		# Command that will turn this switch off
switch.fan0.output_pin                       	e.13              		# Pin this module controls
switch.fan0.output_type                      	hwpwm              		# PWM output settable with S parameter in the input_on_comand
#switch.fan0.max_pwm                         	255              		# Set max pwm for the pin default is 255
switch.fan0.kickstart_time                   	100

# Switch module for box fan control
switch.fan1.enable                           	true             		# Enable this module
switch.fan1.input_on_command                 	M2106             		# Command that will turn this switch on
switch.fan1.input_off_command                	M2107             		# Command that will turn this switch off
switch.fan1.output_pin                       	e.9             		# Pin this module controls
switch.fan1.output_type                      	hwpwm              		# PWM output settable with S parameter in the input_on_comand
switch.fan1.ignore_on_halt 						true

# Switch module for electronics compartment fan control
switch.fan2.enable                           	true             		# Enable this module
switch.fan2.input_on_command                 	M1106             		# Command that will turn this switch on
switch.fan2.input_off_command                	M1107             		# Command that will turn this switch off
switch.fan2.output_pin                       	e.11             		# Pin this module controls
switch.fan2.output_type                      	hwpwm              		# PWM output settable with S parameter in the input_on_comand
switch.fan2.max_pwm                          	255              		# Set max pwm for the pin default is 255
switch.fan2.ignore_on_halt 						true

# Switch module for light control
switch.light.enable                          	true             		# Enable this module
switch.light.input_on_command                	M355           			# Command that will turn this switch on
switch.light.input_off_command              	M355 s0           		# Command that will turn this switch off
switch.light.output_pin                      	a.3              		# Pin this module controls
switch.light.output_type                     	hwpwm            		# PWM output settable with S parameter in the input_on_comand
switch.light.pwm_period_ms                   	5
switch.light.ignore_on_halt  		    	 	true


######################## Filament detector ########################
filament_detector.enable						true		 			#This module is activated only if this is set to true
filament_detector.encoder_pin 					b.7

filament_detector.seconds_per_check 			1 						#  , .
filament_detector.minimal_mm_to_check 			1.5 					#     ,  (  1-2-  )

filament_detector.pulses_per_mm 				7.28 					#    1   ( /    1 . (80/21,98)*2=7,28)
filament_detector.extruded_len_to_check 		5 						#       , 
filament_detector.low_error_pcnt 				30 						#  ,  
filament_detector.high_error_pcnt 				50 						#  ,  



########################EndStop and Houming Config########################

## Endstops
endstops_enable                              	true             		# The endstop module is enabled by default and can be disabled here
corexy_homing                                	false            		# Set to true if homing on a hbot or corexy

# X Endstops
alpha_min_endstop                            	c.14   	      			# Pin to read min endstop, add a ! to invert if endstop is NO connected to ground
alpha_homing_direction                       	home_to_min      		# Or set to home_to_max and set alpha_max and uncomment the alpha_max_endstop
alpha_min                                    	0                		# This gets loaded as the current position after homing when home_to_min is set
alpha_max                                    	300              		# This gets loaded as the current position after homing when home_to_max is set
alpha_fast_homing_rate_mm_s                  	50              		# Alpha/X fast homing feedrate in mm/second
alpha_slow_homing_rate_mm_s                  	30               		# Alpha/X slow homing feedrate in mm/second

# Y Endstops
beta_min_endstop                             	c.13		      		# Pin to read min endstop, add a ! to invert if endstop is NO connected to ground
beta_homing_direction                        	home_to_min      		# Or set to home_to_max and set alpha_max and uncomment the alpha_max_endstop
beta_min                                     	0                		# This gets loaded as the current position after homing when home_to_min is set
beta_max                                     	300              		# This gets loaded as the current position after homing when home_to_max is set
beta_fast_homing_rate_mm_s                   	50              		# Beta/Y  fast homing feedrate in mm/second
beta_slow_homing_rate_mm_s                   	30               		# Beta/Y  slow homing feedrate in mm/second

# Z Endstops
gamma_max_endstop                            	c.15! 					# Pin to read min endstop, add a ! to invert if endstop is NO connected to ground
gamma_homing_direction                       	home_to_max      		# Or set to home_to_max and set alpha_max and uncomment the alpha_max_endstop
gamma_min                                    	0                		# This gets loaded as the current position after homing when home_to_min is set
gamma_max                                    	410              		# This gets loaded as the current position after homing when home_to_max is set
gamma_fast_homing_rate_mm_s                  	15               		# Gamma/Z fast homing feedrate in mm/second
gamma_slow_homing_rate_mm_s                  	5                		# Gamma/Z slow homing feedrate in mm/second

alpha_homing_retract_mm                      	5                		# Distance to retract from the endstop after it is hit for alpha/X
beta_homing_retract_mm                       	5                		# Distance to retract from the endstop after it is hit for beta/Y
gamma_homing_retract_mm                      	5                		# Distance to retract from the endstop after it is hit for gamma/Z

alpha_max_travel                             	310              		# Max travel in mm for alpha/X axis when homing
beta_max_travel                              	310              		# Max travel in mm for beta/Y axis when homing
gamma_max_travel                             	410              		# Max travel in mm for gamma/Z axis when homing

## Soft Endstops
soft_endstop.enable         					true         			# Enable soft endstops
soft_endstop.x_min          					0            			# Minimum X position
soft_endstop.x_max          					300          			# Maximum X position

soft_endstop.y_min          					0            			# Minimum Y position
soft_endstop.y_max          					300          			# Maximum Y position

soft_endstop.z_min          					0            			# Minimum Z position
soft_endstop.z_max          					405          			# Maximum Z position

soft_endstop.halt           					false         			# Whether to issue a HALT state when hitting a soft endstop (if false, will just ignore commands that would exceed the limit)


# Optional order in which axis will home, default is they all home at the same time,
# If this is set it will force each axis to home one at a time in the specified order
homing_order                                 	XYZ              		# X axis followed by Y then Z last
endstops_pre_home_protect 						true 					#     ,     
prehome_axis_protect 							true 					#        home
prehome_move_protect 							false 					#              home

######################## Z Probe ########################

# Z probe
zprobe.enable                                	false		          	# set to true to enable a zprobe

leveling-strategy.rectangular-grid.enable 		false     				# The strategy must be enabled in the config, as well as the zprobe module.

babystepping_enable 							true 					#         .

Z_position_setup_enabled 						true 					#     

# Manual Z probe points
manual_table_points_x                   10|290|290|10
manual_table_points_y                   10|10|290|290

######################## Standby ########################

printer.idle_time 								120	 					#  , 
printer.temp_to_standby 						40 						# ,    Standby.      
printer.standby_led_num 						0						#           Standby
printer.standby_led_rgb 						60|60|60 				#   RGB. 60|60|60 -   ,   ,   .
										

######################## Display Config ########################

panel.enable                                 	true             		# set to true to enable the panel code
panel.lcd                                    	viki2            		# set type of panel
panel.spi_channel                              	1              			# spi channel to use  spi_channel = 1  -> mosi = b.15; miso = b.14; sclk = b.13; 

panel.spi_cs_pin                               	a.7            			# spi chip select     LCD_EN
panel.a0_pin                                   	a.4            			# data/command select LCD_RS
panel.rst_pin		    	   					a.5            			# reset panel         LCD_D4
panel.contrast                                 	10             			#  0-
panel.reverse                                 	true            		#   

panel.encoder_a_pin                             e.0!^
panel.encoder_b_pin                             e.1^
panel.click_button_pin                          e.4!^
panel.buzz_pin                                  e.5
panel.system_sd_access                          true

neopixel.enable			      					true
panel.timeroff                                  0
neopixel.lowspeed 								true

######################## Protection parameters and logging ########################
panel.checkfile									true					#       .
panel.max_checkfiletime 						0						#      . 0 -  .
pause_on_reading_error 							true 					#  ,      .     .
error_logger.enable 							false					#     

######################## hanging plastic ########################
retrieve_gcode                          G91|G1_E15_F1500|G1_E-50_F5000|G1_E-640_F4000|G90 		#   
fill_gcode                              G91|G1_E640_F4000|G90									#   

######################## Gcode execution ########################
#on_boot_gcode_enable   				true  
#on_boot_gcode   						/sd/go.g
after_suspend_gcode 					G91|G1_E-5_F4000|G1_Z5_F1500|G90|G1_X50_Y10_F6000  		#     600 -  , m600.1   .
after_resume_gcode 						G91|G1_E5.5_F4000|G90 									#     
after_abort_gcode 						G91|G1_Z5_E-4|G90|G28_X_Y|M17|M107|M18	 				#    . ( / )
after_play_gcode 						M107.2|M18 												#    .
before_home_Z_move 						5 														#    ,     

########################Driver Config########################

# X Axis Driver
simpledriver.drv1.enable 					true
simpledriver.drv1.type 						uart220x
simpledriver.drv1.num 						1
simpledriver.drv1.uart_pin 					4  						#pin number on driver for uart //  pin 4 or 5 // 4=ms3 5=pdn // default 4
simpledriver.drv1.GCONF 					0x000001C0 				# pdn_disable, microstep by register
simpledriver.drv1.CHOPCONF 					0x10008003 				
simpledriver.drv1.PWMCONF 					0xC80D0E24 				
simpledriver.drv1.TPOWERDOWN 				0x00000014
simpledriver.drv1.rsense 					0.11
simpledriver.drv1.run_ma 					1050 					#    mA  
simpledriver.drv1.hold_ma 					600 					#    mA
simpledriver.drv1.microsteps 				16   					# 
simpledriver.drv1.TPWMTHRS 					0x00000000
simpledriver.drv1.shortprotect 				true

# Y Axis Driver
simpledriver.drv2.enable 					true
simpledriver.drv2.type 						uart220x
simpledriver.drv2.num 						2
simpledriver.drv2.uart_pin 					4
simpledriver.drv2.GCONF 					0x000001C0 	
simpledriver.drv2.CHOPCONF 					0x10008003
simpledriver.drv2.PWMCONF 					0xC80D0E24 				
simpledriver.drv2.TPOWERDOWN 				0x00000014		
simpledriver.drv2.rsense 					0.11
simpledriver.drv2.run_ma 					1050 					#   mA 
simpledriver.drv2.hold_ma 					600 					#   mA
simpledriver.drv2.microsteps 				16	
simpledriver.drv2.TPWMTHRS 					0x00000000
simpledriver.drv2.shortprotect 				true


# Z Axis Driver
simpledriver.drv3.enable 					true
simpledriver.drv3.type 						uart220x
simpledriver.drv3.num 						3
simpledriver.drv3.uart_pin 					4
simpledriver.drv3.GCONF 					0x000001C0 
simpledriver.drv3.PWMCONF 					0xC40D0E24
simpledriver.drv3.microsteps 				16
simpledriver.drv3.rsense 					0.11
simpledriver.drv3.run_ma 					900 					#   mA   
simpledriver.drv3.hold_ma 					400 					#   mA
simpledriver.drv3.TPWMTHRS 					0      					# block 2208 driver disable tmc bug
simpledriver.drv3.shortprotect 				true

# E0 Axis Driver
simpledriver.drv4.enable 					true
simpledriver.drv4.type 						uart220x
simpledriver.drv4.num 						4
simpledriver.drv4.uart_pin 					4
simpledriver.drv4.GCONF 					0x000001C0 
simpledriver.drv4.microsteps 				16
simpledriver.drv4.rsense 					0.11
simpledriver.drv4.run_ma 					900 					#   mA 
simpledriver.drv4.hold_ma 					600 					#   mA
simpledriver.drv4.TPWMTHRS 					0
simpledriver.drv4.shortprotect 				true

# E1 Axis Driver
simpledriver.drv5.enable	      				false


########################Preheat Config########################

preheat.names                           PLA|ABS|PETG|Wax
preheat.head_temps                      200|230|220|80
preheat.bed_temps                       70|90|90|0